package org.nightrunner.d3.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Indexed;

/**
 * 词缀值表
 * 
 * @author NightRunner
 * @Date 2012-7-26
 * @version 1.0
 */

@Entity
@Indexed
@Table(name = "d3_prefix_value", catalog = "d3")
public class PrefixValue implements java.io.Serializable {

	private static final long serialVersionUID = 4628199428986628718L;

	@DocumentId
	private String prefixValueId;

	/**
	 *前缀
	 */
	private Prefix prefix;

	/**
	 * 属性
	 */
	private Property property;

	/**
	 * 最大值
	 */
	private Integer max;

	/**
	 * 最小值
	 */
	private Integer min;

	/**
	 * 排序
	 */
	private Integer sort;

	@Id
	@GeneratedValue(generator = "paymentableGenerator")
	@GenericGenerator(name = "paymentableGenerator", strategy = "uuid")
	@Column(name = "prefix_value_id", nullable = false, length = 32)
	public String getPrefixValueId() {
		return this.prefixValueId;
	}

	@ManyToOne
	@JoinColumn(name = "prefix_id", referencedColumnName = "prefix_id", nullable = false)
	public Prefix getPrefix() {
		return prefix;
	}

	@Column(name = "max")
	public Integer getMax() {
		return max;
	}

	@Column(name = "min")
	public Integer getMin() {
		return min;
	}

	@OneToOne(targetEntity = Property.class)
	@JoinColumn(name = "property_id", referencedColumnName = "property_id", nullable = false)
	public Property getProperty() {
		return property;
	}

	@Column(name = "sort")
	public Integer getSort() {
		return sort;
	}

	/** default constructor */
	public PrefixValue() {
	}

	/** minimal constructor */
	public PrefixValue(String prefixValueId) {
		this.prefixValueId = prefixValueId;
	}

	public void setPrefixValueId(String prefixValueId) {
		this.prefixValueId = prefixValueId;
	}

	public void setProperty(Property property) {
		this.property = property;
	}

	public void setMax(Integer max) {
		this.max = max;
	}

	public void setMin(Integer min) {
		this.min = min;
	}

	public void setSort(Integer sort) {
		this.sort = sort;
	}

	public void setPrefix(Prefix prefix) {
		this.prefix = prefix;
	}
}
